<?php

class forum_model extends my_model{
	function __construct(){
		parent::__construct();
		$this->_prefix = "pos";
		$this->_column = array(
								'id'						=> $this->_prefix."_id",
								'title'					=> $this->_prefix."_title",
								'content'				=> $this->_prefix."_content",
								'usr_ip'				=> $this->_prefix."_usr_ip",
								'status'				=> $this->_prefix."_status",
								'comment_status'=> $this->_prefix."_comment_status",
								'usr_id'				=> $this->_prefix."_usr_id",
								'cat_id'				=> $this->_prefix."_cat_id",
								'typ_id'				=> $this->_prefix."_typ_id",
								'cr_date'				=> $this->_prefix."_cr_date",
								'lu_date'				=> $this->_prefix."_lu_date",
								'lu_uid'				=> $this->_prefix."_lu_uid",
								'update_date'		=> $this->_prefix."_update_date",
								'url'						=> $this->_prefix."_url",
								'type'					=> $this->_prefix."_type",
								'code'					=> $this->_prefix."_code",
								'view'					=> $this->_prefix."_view"
								
			);
		$this->_join_column = array(
								'category_id' 					=> "foc_id",
								'category_name' 				=> "foc_name",
								'category_description'  => "foc_description",
								'category_parent_id'  	=> "foc_parent_id",
								'category_url'  				=> "foc_url"
		);

		$this->_table = "ci_post";
	}

	function get($options = NULL){
		$this->db->where("pos_type","forum");
		$topics = parent::get($options);

    if(!empty($topics)){
    	$this->load->model("images_model","imagesModel");
			foreach ($topics as $key => $value) {
				$topics[$key]["images"] = $this->imagesModel->get(array("where"=>array("pos_id"=>$value["id"])));
				$topics[$key]["categories"] = array_reverse(Util::getCategoryInherit($value["cat_id"],NULL,"forum"));
				$topics[$key]["user"] = $this->ion_auth->user_array($topics[$key]["usr_id"]);
			}
		}
		return $topics;
	}

	function add($options = NULL){
		$this->db->set("pos_type","forum");
		return parent::add($options);
	}
}



?>